package cn.spring.framework.redis.context;

import java.util.concurrent.Future;

/**
 * @author xingkong
 * @Title: RedisCacheContext
 * @Description: redis cache上下文
 * @date 2021/11/12 17:38
 */
public class RedisCacheContext {
    private static ThreadLocal<RedisCacheContext> LOCAL = ThreadLocal.withInitial(RedisCacheContext::new);

    private Future<?> future;

    private RedisCacheContext() {

    }

    /**
     * 获取上下文
     * @return RedisCacheContext
     */
    public static RedisCacheContext getContext() {
        return LOCAL.get();
    }

    /**
     * 设置future
     * @param future
     */
    public void setFuture(Future<?> future) {
        this.future = future;
    }

    public <T> Future<T> getFuture() {
        return (Future<T>) future;
    }
}
